package com.smforj.ssm.mina.service;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 工作线程
 * @desp
 * @author ghj
 * @date 2016-2-28 下午9:57:09
 */
public class WorkThread extends Thread{
	private Runnable target;   //线程执行目标
    private AtomicInteger counter; //计数器 
  
    public WorkThread(Runnable target, AtomicInteger counter) {  
        this.target = target;  
        this.counter = counter;  
    }  
    @Override 
    public void run() {  
        try {  
            target.run();  
        } finally {  
            int c = counter.getAndDecrement();  
            System.out.println("terminate no " + c + " Threads");  
        }  
    }  
}
